import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.*;

/**
 * @author faraday
 * @create 2020-08-27 15:37
 */
public class ExecutorsDemo {

    private static ThreadFactory namedThreadFactory = new
            ThreadFactoryBuilder()
            .setNameFormat("demo-pool-%d").build();
    private static ExecutorService pool = new ThreadPoolExecutor(3, 3,
            0L, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<Runnable>(10), namedThreadFactory, new
            ThreadPoolExecutor.
                    AbortPolicy());
//    private static ExecutorService executor = new ThreadPoolExecutor(10, 10,
//            60L, TimeUnit.SECONDS,
//            new ArrayBlockingQueue(10));

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            pool.execute(new SubThread());
        }
    }
}
